/*
 * Copyright (c) 2008-2013 Haulmont. All rights reserved.
 * Use is subject to license terms, see http://www.cuba-platform.com/license for details.
 */

package com.haulmont.asu.entity;

import com.haulmont.chile.core.annotations.MetaProperty;
import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.cuba.core.entity.StandardEntity;
import com.haulmont.cuba.core.entity.annotation.Listeners;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * Author: Sergey42
 * Date: 14.10.13 12:25
 */
@Table(name = "EXT_CATHEDRAL_CONSULTANT")
@Entity(name = "ext$CathedralConsultant")
@Listeners(value = "com.haulmont.asu.core.listener.CathedralConsultantListener")
@NamePattern("%s|name")
public class CathedralConsultant extends StandardEntity {

    private static final long serialVersionUID = -5321381279873004007L;

    @ManyToOne
    @JoinColumn(name = "CATHEDRAL_EMPLOYEE_ID")
    protected CathedralEmployee cathedralEmployee;

    @Column(name = "START_WORK_DATE")
    @Temporal(TemporalType.DATE)
    protected Date startWorkDate;

    @ManyToOne
    @JoinColumn(name = "CATHEDRA_ID")
    protected Cathedra cathedra;

    @OneToMany(mappedBy = "addConsultant")
    protected List<DiplomaProject> diplomaProjects;

    @MetaProperty
    public String getName() {
        return getCathedralEmployee() != null ? getCathedralEmployee().getName() : "";
    }

    public Date getStartWorkDate() {
        return startWorkDate;
    }

    public void setStartWorkDate(Date startWorkDate) {
        this.startWorkDate = startWorkDate;
    }

    public CathedralEmployee getCathedralEmployee() {
        return cathedralEmployee;
    }

    public void setCathedralEmployee(CathedralEmployee cathedralEmployee) {
        this.cathedralEmployee = cathedralEmployee;
    }

    public Cathedra getCathedra() {
        return cathedra;
    }

    public void setCathedra(Cathedra cathedra) {
        this.cathedra = cathedra;
    }

    public List<DiplomaProject> getDiplomaProjects() {
        return diplomaProjects;
    }

    public void setDiplomaProjects(List<DiplomaProject> diplomaProjects) {
        this.diplomaProjects = diplomaProjects;
    }
}
